package com.dlwx.parttimetalent.ui;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.base.BaseActivity;
import com.dlwx.parttimetalent.comm.Constant;
import com.dlwx.parttimetalent.utils.SPUtils;
import com.dlwx.parttimetalent.utils.StringUtil;
import com.dlwx.parttimetalent.utils.ToastUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SetNickNameActivity extends BaseActivity {

    @BindView(R.id.title_left_one_btn)
    ImageView titleLeftOneBtn;
    @BindView(R.id.et_nickname)
    EditText etNickname;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;
    @BindView(R.id.tv_tips)
    TextView tvTips;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_nick_name);
        ButterKnife.bind(this);
        initView();

    }

    private void initView() {
        titleLeftOneBtn.setVisibility(View.VISIBLE);
    }

    @OnClick({R.id.title_left_one_btn, R.id.tv_confirm,R.id.tv_tips})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_left_one_btn:
                this.finish();
                break;
            case R.id.tv_tips:
                tvTips.setVisibility(View.GONE);
                break;
            case R.id.tv_confirm:
                String name = etNickname.getText().toString();
                if (TextUtils.isEmpty(name)) {
                    ToastUtils.toastForShort(this, "昵称不能为空");
                    return;
                }
                if (!StringUtil.isConSpeCharacters(name)) {
                    ToastUtils.toastForShort(this, "昵称只能汉字、字母、数字和下划线及破折号");
                    return;
                }
                SPUtils.put(this, Constant.NICK_NAME, name);
                startActivity(new Intent(this, SetAgeActivity.class));
                break;
        }
    }
}
